package mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface WorkScoreMapper {

    @Select("select student_scores from work_score where user_id = #{id} and work_id = #{workId}")
    Double selectScoreByUserIdWorkId(Integer id, Integer workId);

    @Insert("insert into work_score (user_id, work_id, student_scores) VALUES (#{userId},#{workId},#{scores})")
    void save(Double scores, Integer userId, Integer workId);

    @Select("select student_scores from work_score where work_id = #{workId} and user_id = #{userId}")
    Double getScoreById(Integer workId, Integer userId);

    @Update("update work_score set student_scores = #{scores} where user_id = #{userId} and work_id = #{workId}")
    void update(double scores, Integer userId, Integer workId);
}
